/**
 * @Author: Bobby
 * @Date: 2022-03-17 09:29:06
 * @LastEditTime: 2022-03-17 09:55:39
 * @LastEditors: Bobby
 * @Description:
 * @FilePath: \wms-v2\src\common\project\store\modules\tmp.js
 * @CIMC-V2
 */
// 临时使用
const state = () => ({
  buttonId: '', //点击按钮id
  nowMenuCode: '', //当前路由参数 也就是菜单code
  pageLoading: false,
  fingerprint: '',
  regular: '', //后台返回小数位数
  pages: {},
})
const getters = {
  getButtonId: (state) => state.buttonId,
  getNowMenuCode: (state) => state.nowMenuCode,
  getPageLoading: (state) => state.pageLoading,
  getFingerprint: (state) => state.fingerprint,
  getRegular: (state) => state.regular,
}
const mutations = {
  setNowMenuCode(state, router) {
    state.nowMenuCode = router.name || ''
  },
  setButtonId(state, id) {
    state.buttonId = id || ''
  },
  setPageLoading(state, val) {
    state.pageLoading = val
  },
  setFingerprint(state, val) {
    state.fingerprint = val
  },
  setRegular(state, val) {
    state.regular = val
  },
  setPages(state, { pageId, uiId }) {
    if (uiId != undefined) {
      if (state.pages[pageId]) {
        state.pages[pageId][uiId] = 'success' //uiInfo
      } else {
        state.pages[pageId] = {
          [uiId]: 'success',
        }
      }
    }
  },
}
const actions = {
  setNowMenuCode({ commit }, router) {
    commit('setNowMenuCode', router)
  },
  setButtonId({ commit }, id) {
    commit('setButtonId', id)
  },
  setPageLoading({ commit }, val) {
    commit('setPageLoading', val)
  },
  setFingerprint({ commit }, val) {
    commit('setFingerprint', val)
  },
  setRegular({ commit }, val) {
    commit('setRegular', val)
  },
  setPages({ commit }, data) {
    commit('setPages', data)
  },
}
export default { state, getters, mutations, actions }
